home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10763 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  67 lines

  1. Path: nrchh52.rich.nt.com!news
  2. From: Joseph Bell <jobell@bnr.ca>
  3. Newsgroups: comp.lang.misc,comp.lang.c,comp.lang.pl1,comp.lang.apl
  4. Subject: Re: GOTO controversy
  5. Date: Tue, 19 Mar 1996 15:50:26 -0600
  6. Organization: Bell-Northern Research
  7. Message-ID: <314F2C22.3D11@bnr.ca>
  8. References: <rcshlds.1.000A6705@mailserv.mta.ca> <4grt4e$8fg@goanna.cs.rmit.EDU.AU> <4hl8mt$4po@newshost.cyberramp.net> <4hlg11$dd7@news1.mnsinc.com> <4hpits$1p1v@b.stat.purdue.edu> <4i0fj8$sd3@tierra.santafe.edu> <3147F456.50F0@simi.is> <4imrjm$pqm@netline-fddi.jpl.nasa.gov>
  9. NNTP-Posting-Host: 47.186.65.32
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=iso-8859-1
  12. Content-Transfer-Encoding: 8bit
  13. X-Mailer: Mozilla 2.01 (X11; I; HP-UX A.09.05 9000/712)
  14.  
  15. Sam Sirlin wrote:
  16. > In article <3147F456.50F0@simi.is>, Bj÷rn Helgason <bjornhp@simi.is> writes:
  17. > |> In most instances they are not needed. I might add that in ALL cases
  18. > |> you could avoid GOTOs and LOOPs if you really put your mind to it.
  19.  
  20. At the core, all branch instructions are gotos, they are just called
  21. branches.
  22. The goto statement is admonished only when it is used to jump all around
  23. the
  24. code in "spaghetti" like manner.
  25.  
  26. 10 A = 0
  27. 20 A = A + 1
  28. 30 PRINT A
  29. 40 IF A = 10 THEN GOTO 50 ELSE GOTO 20
  30. 50 PRINT "Finished"
  31.  
  32. is more "cleanly" handled saying 
  33.  
  34. for (i = 1; i <= 10; i++)
  35.     printf ("%d\n", i);
  36.  
  37. but they are nonetheless the same when it comes to ml.
  38.  
  39. but what makes more sense:
  40.  
  41. if (a == 10)
  42.     printDone();
  43.  
  44. void printDone(void)
  45. {
  46.     printf ("Done.\n");
  47. }
  48.  
  49. OR
  50.  
  51. 10 IF A = 10 THEN GOSUB 999
  52. 20
  53. 30
  54. 40
  55. ...
  56. 998 END
  57. 999 PRINT "DONE."
  58. 1000 RETURN
  59.  
  60. -- 
  61. Joseph A. Bell (NOT Bret Bieghler) jobell@bnr.ca
  62. Northern Telecom / Bell-Northern Research
  63. "What?  Evacuate now, in our moment of triumph?  Surely you overestimate
  64. their chances."
  65.